package api.ws.server;

import basic.common.Global;
import basic.common.util.DubboUtils;
import basic.common.ws.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.data.r2dbc.repository.config.EnableR2dbcRepositories;

import java.util.TimeZone;

/**
 * @创建人 xiaojiancheng
 * @时间 2020/5/24
 * @描述 $k$
 */
@SpringBootApplication
@EnableR2dbcRepositories(basePackages = "repository")
@EnableDubbo
@EnableDiscoveryClient
@Slf4j
public class WsMain {
    public static void main(String[] args) {
        DubboUtils.initDubboRegistryHost();
        int k = 5;
        System.setProperty("nacos.logging.default.config.enabled", "false");
        TimeZone.setDefault(TimeZone.getTimeZone("Asia/Shanghai"));
        ConfigurableApplicationContext run = SpringApplication.run(WsMain.class, args);
        Global.map().put("run",run);
    }


    @Bean
    public UserContainer userContainer(){
        return new UserContainerImpl();
    }

    @Bean
    public Server server(){
        return new Server();
    }

    @Bean
    public MessageConvert messageConvert(){
        return new DefaultMessageConvertImpl();
    }
}
